const directiveObj = {
  imgerror: {
    inserted(dom, obj, vnode) {
      obj.value = obj.value || require('@/assets/common/head.jpg')
      dom.src = dom.src || obj.value
      dom.onerror = () => {
        dom.src = obj.value
      }
    },
    componentUpdated(dom, obj) {
      obj.value = obj.value || require('@/assets/common/head.jpg')
      dom.src = dom.src || obj.value
    },
    unbind(dom) {
      dom.onerror = null
    }
  }
}
export default {
  install(Vue) {
    Object.keys(directiveObj).forEach((item) => {
      Vue.directive(item, directiveObj[item])
    })
  }
}
